import express from "express";
import dotenv from "dotenv";
import morgan from "morgan"; 
import "./schedule/index";
import { AppDataSource } from "./type-orm";
import router from "./router";


dotenv.config();

export const app = express();

app.use(express.json({limit: '50mb'}));
app.use(express.urlencoded({ extended: true }));
app.use(morgan('combined'));


// 从环境变量中获取端口号，若未设置则使用默认值 8888
const port = process.env.PORT || 8888;

AppDataSource.initialize().then(() => {
 

  router();

  console.log(`Server is running at http://localhost:${port}`);
  app.listen(port);
})





